// pages/opreation/studentAssignment/list/index.js
import {
  request
} from '../../../../request';
Page({

  /**
   * 页面的初始数据
   */
  data: {
    teacherList: [],
    modalName: null
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.initData();
  },
  initData() {
    request("/gym/studentAssignment/list", "GET").then(resopnse => {
      this.setData({
        teacherList: resopnse.rows
      });
    })
  },
  pageBack() {
    wx.navigateBack({
      delta: 1
    });
  }, // ListTouch触摸开始
  ListTouchStart(e) {
    this.setData({
      ListTouchStart: e.touches[0].pageX
    })
  },

  // ListTouch计算方向
  ListTouchMove(e) {
    this.setData({
      ListTouchDirection: e.touches[0].pageX - this.data.ListTouchStart > 0 ? 'right' : 'left'
    })
  },

  // ListTouch计算滚动
  ListTouchEnd(e) {
    if (this.data.ListTouchDirection == 'left') {
      this.setData({
        modalName: e.currentTarget.dataset.target
      })
    } else {
      this.setData({
        modalName: null
      })
    }
    this.setData({
      ListTouchDirection: null
    })
  },
  modify(e) {
    var item = e.currentTarget.dataset['item'];
    wx.navigateTo({
      url: '/pages/opreation/studentAssignment/student/index?id=' + item.userId,
    })
  }
})